# 作者：陈睿-cruise
# 2025年02月19日18时54分15秒
# 2979386061@qq.com
import re

# 示例文本
text = "Hello, my phone number is 123-456-7890 and my email is test@example.com. Visit https://example.com for more info."

# 1. 匹配连续的数字
matches_digits = re.findall(r'\d+', text)
print("匹配连续的数字:", matches_digits)  # 输出: ['123', '456', '7890']

# 2. 匹配连续的字母
matches_letters = re.findall(r'[a-zA-Z]+', text)
print("匹配连续的字母:", matches_letters)  # 输出: ['Hello', 'my', 'phone', 'number', 'is', 'and', 'my', 'email', 'is', 'test', 'example', 'com', 'Visit', 'https', 'example', 'com', 'for', 'more', 'info']

# 3. 匹配连续的字母或数字
matches_alnum = re.findall(r'\w+', text)
print("匹配连续的字母或数字:", matches_alnum)  # 输出: ['Hello', 'my', 'phone', 'number', 'is', '123', '456', '7890', 'and', 'my', 'email', 'is', 'test', 'example', 'com', 'Visit', 'https', 'example', 'com', 'for', 'more', 'info']

# 4. 匹配连续的空白字符
matches_spaces = re.findall(r'\s+', text)
print("匹配连续的空白字符:", matches_spaces)  # 输出: [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']

# 5. 匹配连续的任意字符（非贪婪模式）
matches_any = re.findall(r'.+?', text)
print("匹配连续的任意字符（非贪婪模式）:", matches_any)  # 输出: ['H', 'e', 'l', 'l', 'o', ',', ' ', 'm', 'y', ' ', 'p', 'h', 'o', 'n', 'e', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 'i', 's', ' ', '1', '2', '3', '-', '4', '5', '6', '-', '7', '8', '9', '0', ' ', 'a', 'n', 'd', ' ', 'm', 'y', ' ', 'e', 'm', 'a', 'i', 'l', ' ', 'i', 's', ' ', 't', 'e', 's', 't', '@', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', '.', ' ', 'V', 'i', 's', 'i', 't', ' ', 'h', 't', 't', 'p', 's', ':', '/', '/', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', ' ', 'f', 'o', 'r', ' ', 'm', 'o', 'r', 'e', ' ', 'i', 'n', 'f', 'o', '.']

# 6. 匹配连续的任意字符（贪婪模式）
matches_any_greedy = re.findall(r'.+', text)
print("匹配连续的任意字符（贪婪模式）:", matches_any_greedy)  # 输出: ['Hello, my phone number is 123-456-7890 and my email is test@example.com. Visit https://example.com for more info.']

# 7. 匹配邮箱地址
matches_email = re.findall(r'\w+@\w+\.\w+', text)
print("匹配邮箱地址:", matches_email)  # 输出: ['test@example.com']

# 8. 匹配 URL
matches_url = re.findall(r'https?://\S+', text)
print("匹配 URL:", matches_url)  # 输出: ['https://example.com']

# 9. 匹配日期格式（YYYY-MM-DD）
text_with_date = "Today is 2023-10-05."
matches_date = re.findall(r'\d{4}-\d{2}-\d{2}', text_with_date)
print("匹配日期格式:", matches_date)  # 输出: ['2023-10-05']

# 10. 匹配重复的单词
text_with_repeats = "This is is a test test."
matches_repeats = re.findall(r'\b(\w+)\b\s+\1', text_with_repeats)
print("匹配重复的单词:", matches_repeats)  # 输出: ['is', 'test']